<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>验证diffing算法</title>
</head>
<body>
  <div id="test"></div>

  <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
  <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
  <script src="https://cdn.staticfile.org/prop-types/15.6.1/prop-types.js"></script>

  <script type="text/babel">
    class Time extends React.Component {
      state = {date: new Date()}

      componentDidMount() {
        setInterval(() => {
          this.setState({
            date: new Date()
          })
        }, 1000)
      }
      
      render() {
        return (
          <div>
            <h1>hello</h1>   {/* 这里不会更新 */}
            <input type="text"/>  {/* 这里不会更新 */}
            <p>
              现在是：{this.state.date.toTimeString()}      {/*这里会更新*/}
              <input type="text"/>      {/* 这里不会更新，因为diffing算法会对比每一个标签 */}
            </p>  
          </div>
        )
      }
    }
    ReactDOM.render(<Time />, document.getElementById('test'))

  </script>
  
</body>
</html>